﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HalconDotNet;
using MachineVision.Core;
using MachineVision.Shared.Controls;
using Microsoft.Win32;
using Prism.Commands;

namespace MachineVision.TemplateMatch.ViewModels
{
    public class DrawShapeViewModel : NavigationViewModel
    {
        public DrawShapeViewModel()
        {
            DrawObjectInfos = new ObservableCollection<DrawingObjectInfo>();
        }

        private DelegateCommand _cmdImportImage;
        public DelegateCommand CmdImportImage =>
            _cmdImportImage ?? (_cmdImportImage = new DelegateCommand(ExecuteCmdImportImage));

        void ExecuteCmdImportImage()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            if (dialog.ShowDialog() == true)
            {
                HOperatorSet.ReadImage(out HObject timg, dialog.FileName);
                Image = timg;
            }
        }

        private HObject _image;
        public HObject Image
        {
            get { return _image; }
            set { SetProperty(ref _image, value); }
        }

        private ObservableCollection<DrawingObjectInfo> _drawObjectInfos;
        public ObservableCollection<DrawingObjectInfo> DrawObjectInfos
        {
            get { return _drawObjectInfos; }
            set { SetProperty(ref _drawObjectInfos, value); }
        }
    }
}
